import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
// import { apiJsonWatcher } from 'api-factory'
import { ApiGenerationPlugin } from "api-factory-plugin/apiGeneration";
//import { ApiJsonWatcherPlugin } from './apiJsonWatcher'
//import apiJsonWatcherPlugin from 'api-factory-plugin/apiJsonWatcher';
//import ApiJsonWatcherPlugin from "api-factory-plugin";

const JSON_FILE_PATH = "./api.json";
const MODULE_DECL_PATH = "./module_declarations.toml";
const API_FILE_PATH = "./src/api.ts";
const GEN_API_CMD = `gen_api -i ${JSON_FILE_PATH} -m ${MODULE_DECL_PATH} -n ${API_FILE_PATH}`;

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // ant-design-vue 自动按需引入组件
    Components({
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, // css in js
        }),
      ],
    }),
    ApiGenerationPlugin({
      jsonFilePath: JSON_FILE_PATH,
      moduleDeclarationPath: MODULE_DECL_PATH,
      outputFilePath: API_FILE_PATH,
    }),
  ],
});
